package org.example.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RestController;

/**
 * 限流实战
 *
 * @since 2022/7/12
 **/
@RestController
@Slf4j
public class RRateLimiterController {

  /*  @Autowired
    private RedissonClient redisson;

    private RRateLimiter rateLimiter;

    @PostConstruct
    public void initRateLimiter() {
        RRateLimiter ra = redisson.getRateLimiter("rate-limiter");
        ra.setRate(RateType.OVERALL, 6, 4, RateIntervalUnit.SECONDS);
        rateLimiter = ra;
    }

    @GetMapping("/rate/limiter")
    public String testRateLimiter() {
        boolean b = rateLimiter.tryAcquire();
        if (b) {
            return "ok";
        }
        return "fail";
    }*/

}
